<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/' }">订单</el-breadcrumb-item>
      <el-breadcrumb-item><a href="/">到货提醒</a></el-breadcrumb-item>
    </el-breadcrumb>

    <!-- 卡片组件 -->
    <el-card class="box-card" style="margin-top:15px;margin-bottom:20px">
      <div slot="header" class="clearfix">
        <i class="el-icon-search"></i>
        <span>筛选查询</span>
      </div>
      <!-- 查询表单开始 -->
      <el-form :inline="true" :model="searchMap" class="demo-form-inline">
        
        <el-form-item label="输入搜索：">
          <el-input v-model="searchMap.id" placeholder="商品名称/商品货号"></el-input>
        </el-form-item>
        <el-form-item label="提醒状态：">
          <el-input v-model="searchMap.receiverMobile" placeholder="收货人姓名/手机号码"></el-input>
        </el-form-item>
        <el-form-item label="设置时间：">
          <el-date-picker type="date" placeholder="请选择时间" v-model="searchMap.pay_time" style="width: 100%;"></el-date-picker>
        </el-form-item>
        
        <el-form-item>
          <el-button type="primary" icon="el-icon-search"  @click="onSubmit">搜索</el-button>
        </el-form-item>
        <!-- 按钮组 -->
        <span style="float:right;">
            <el-button size="medium">一键确认收货</el-button>
            <el-button icon="el-icon-refresh" style="float: right"  @click="reload">刷新</el-button>
        </span>
      </el-form>
    </el-card>

    <!-- 表格开始 -->
    <el-table :data="tableData" stripe style="width: 100%">
      <el-table-column
        type="selection"
        width="55">
      </el-table-column>
      <el-table-column prop="id" label="订单编号"></el-table-column>
      <el-table-column prop="createTime" label="提交时间" width="230">
          <template slot-scope="scope">
          {{scope.row.createTime | dateFormat }}
        </template>
      </el-table-column>
      <el-table-column prop="username" label="用户账号" width="170"></el-table-column>
      <el-table-column prop="receiverContact" label="收货人" width="170"></el-table-column>
      <el-table-column prop="payMoney" label="订单金额" width="140"></el-table-column>
      <el-table-column prop="orderStatus" label="订单状态" width="130">
        <template>
          <el-tag type="warning" size="small">待发货</el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="createTime" label="订单应收货时间" width="230">
          <template slot-scope="scope">
          {{scope.row.createTime | dateFormat }}
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini" type="text" @click="lookOrder(scope.$index, scope.row)" >查看订单</el-button>
          <el-button size="mini" type="text" >确认收货</el-button>
        </template>
      </el-table-column>
    </el-table> 
    <!-- 表格结束 -->

    <!-- 分页开始 -->
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="pageSizeList"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    ></el-pagination>
    <!-- 分页结束 -->
  </div>
</template>

<script>

export default {
  async created () {
    this.getBrandList()
  },
  data () {
    return {
      tableData: [], // 表格数据
      currentPage: 1, // 当前页码
      pageSize: 10, // 页大小
      pageSizeList: [10, 20, 50, 100, 500], // 页大小列表
      total: 0, // 总记录数
      searchMap: {}, // 查询表单对象
      // 添加表单
      // 表单label的宽度
      formLabelWidth: '120px'
    }
  },
  methods: {
    // 查询列表
    async getBrandList () {
      const { data: res } = await this.$http.post(`/orders/order/orderMessage?page=${this.currentPage}&size=${this.pageSize}`, this.searchMap)
      this.tableData = res.rows
      this.total = res.total
    },
    // 页大小改变事件
    handleSizeChange (val) {
      this.pageSize = val
      this.getBrandList()
    },
    // 页码改变事件
    handleCurrentChange (val) {
      this.currentPage = val
      this.getBrandList()
    },
    // 查询
    onSubmit () {
      this.getBrandList()
    },
    // 刷新
    reload () {
      window.location.reload()
    },
    //查看订单
    lookOrder (index, row) {
      this.$router.push({
        path: "/order/look_order",
        query: {
          orderId: row.id
        }
      })
    }
  }
}
</script>

<style scoped>

</style>>
